{template 'header', 'member'}
<div id="head-bar">
<div class="head-bar">
<div class="head-bar-back">
<a href="{$back_link}" data-direction="reverse"><img src="{DT_MOB}static/img/icon-back.png" width="24" height="24"/><span>返回</span></a>
</div>
<div class="head-bar-right">
<a href="?action=index"><span>订阅</span></a>
</div>
</div>
<div class="head-bar-fix"></div>
</div>


<form method="post" action="?" ata-ajax="false" onsubmit="return Mcheck();">
<div class="ui-form">
<div class="blank-16"></div>
<div>
{loop $TYPE $k $v}
<input type="checkbox" name="typeids[]" value="{$v[typeid]}" id="type_{$v[typeid]}" {if in_array($v[typeid], $mytypeids)}checked{/if}/><label for="type_{$v[typeid]}"> {$v[typename]}</label><br/>
{/loop}
</div>
<div class="list-inp"><div class="bd-b"><input type="email" name="email" id="email" placeholder="电子邮箱" onblur="window.scrollTo(0,0);"/></div></div>
<div class="list-inp"><div style="height:54px;"  class="bd-b">{template 'captcha', 'chip'}</div></div>
<div class="list-inp"><div class="bd-b"><a href="javascript:;" class="b" onclick="Msend();" id="send">发送邮件</a><span id="sendok" class="f_r f_green"></span></div></div>
<div class="list-inp"><div class="bd-b"><input type="tel" name="code" id="code" placeholder="邮件验证码" onblur="window.scrollTo(0,0);"/></div></div>
<div class="blank-16"></div>
<input type="submit" name="submit" class="btn-green" value="订 阅"/>
<div class="blank-16"></div>
<input type="button" class="btn" value="退 订" onclick="Dsheet('<a href=&#34;?action=cancel&#34;><span style=&#34;color:red&#34;>退订</span></a>', '取消', '确定要退订所有订阅吗？');"/>
<div class="blank-32"></div>
</div>
</form>
<script type="text/javascript">
function Mcheck() {
	if(Dd('email').value.length < 6) {
		Dtoast('请输入电子邮箱');
		return false;
	}
	if(Dd('code').value.length < 6) {
		Dtoast('请输入邮件验证码');
		return false;
	}
	if(!Dd('read').checked) {
		Dtoast('请阅读并同意服务条款');
		return false;
	}
	return true;
}
function Mstop() {
	var i = 60;
	var interval=window.setInterval(
		function() {
			if(i == 0) {
				$('#send').html('发送邮件');
				$('#sendok').html('');
				clearInterval(interval);
			} else {
				$('#send').html('重新发送('+i+'秒)');
				i--;
			}
		},
	1000);
}
function Msend() {
	if($('#send').html().indexOf('秒') != -1) {
		Dtoast('请耐心等待');
		return false;
	}
	if(Dd('email').value.length < 6) {
		Dtoast('请输入电子邮箱');
		return false;
	}
	if($('#ccaptcha').html().indexOf('ok.png') == -1) {
		Dtoast('请填写验证码');
		return false;
	}
	$.post('nomail.php', 'action=sendmail&sid={$_sid}&email='+Dd('email').value+'&captcha='+Dd('captcha').value, function(data) {
		if(data == 'ok') {
			$('#sendok').html('邮箱发送成功');			
			Mstop();return;
		} else if(data == 'format') {
			Dtoast('邮箱格式错误');
		} else if(data == 'captcha') {
			Dtoast('验证码错误');
		} else if(data == 'exist') {
			Dtoast('电子邮箱已经被注册');
		} else if(data == 'max') {
			Dtoast('发送次数过多');
		} else if(data == 'fast') {
			Dtoast('发送频率过快');
		} else {
			Dtoast('发送失败'+data);
		}
		reloadcaptcha();
	});
}
$(function(){
	$('#captcha').css({'width':'120px','border':'none','padding':'0','font-size':'16px','margin-top':'10px'});
});
</script>

{template 'footer', 'member'}